package com.propertypoint.service.business;

import java.util.ArrayList;
import java.util.Map;
import java.util.List;







import com.propertypoint.exception.FeedErrorException;
import com.propertypoint.presentation.model.Property;
import com.propertypoint.service.general.PropertyFeedProcessStratergy;
import com.propertypoint.service.general.PropertyFeedService;
import com.propertypoint.util.PropertyFeedFactory;


public class PropertyFeedServiceImpl implements PropertyFeedService {
	
	private List<Property> searchResult; 

	@Override
	public List<Property> searchProperty(Map<String, String[]> parameterMap) {
		
		List<PropertyFeedProcessStratergy> feedList =  PropertyFeedFactory.getInstance().getFeedStratergyList();
		searchResult = new ArrayList<Property>();
		for(PropertyFeedProcessStratergy statergy : feedList){			
			try {
				searchResult.addAll(statergy.processFeed(parameterMap));
			} catch (FeedErrorException e) {
				
				e.printStackTrace();
			}
		}
		
//		searchResult=new ArrayList<Property>();
		
//		Property p1=new Property();
//		p1.setTitle("YISHUN AVENUE 5for Rent");
//		p1.setDescription("S$ 2,000 month,HDB 3NG,Area: 730 sqft, District 27 HDB located at101 YISHUN AVENUE 5for Rent.Yishun Avenue 5 For Rent - 730 Sqft");
//		p1.setLink("http://property.singaporeexpats.com/property-listing/471888/rent/YISHUN-AVENUE-5");
//		p1.setPublishDate("4/9/2014");
//		
//		Property p2=new Property();
//		p2.setTitle("YISHUN RING ROADfor Rent");
//		p2.setDescription("S$ 2,000 / month,HDB 3NG,Area: 732 sqft, District 27 HDB located at116 YISHUN RING ROADfor Rent.Yishun Ring Road For Rent - 732 Sqft");
//		p2.setLink("http://property.singaporeexpats.com/property-listing/473287/rent/YISHUN-RING-ROAD");
//		p2.setPublishDate("3/9/2014");
		
		/*Property p3=new Property();
		p3.setTitle(title);
		p3.setDescription(description);
		p3.setLink(link);
		p3.setPublishDate(publishDate);
		
		Property p4=new Property();
		p4.setTitle(title);
		p4.setDescription(description);
		p4.setLink(link);
		p4.setPublishDate(publishDate);
		
		Property p5=new Property();
		p5.setTitle(title);
		p5.setDescription(description);
		p5.setLink(link);
		p5.setPublishDate(publishDate);*/
//		searchResult.add(p1);
//		searchResult.add(p2);
		return searchResult;
	}

	public List<Property> getSearchResult() {
		return searchResult;
	}

	public void setSearchResult(List<Property> searchResult) {
		this.searchResult = searchResult;
	}

	
	

}
